<?php
// +----------------------------------------------------------------------
// | 有小象汇 自研正版源码 赋能开发者
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 http://www.uxphp.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 有小象汇并不是自由软件，未经许可不能去掉有小象汇相关版权
// +----------------------------------------------------------------------
// | Author:  有小象汇
// +----------------------------------------------------------------------

namespace app\model\car;


use crmeb\basic\BaseModel;
use crmeb\traits\ModelTrait;

/**
 * Class BaseLog
 * @package app\model\shendeng
 */
class BaseLog extends BaseModel
{

    use ModelTrait;

    /**
     * 表主键
     * @var string
     */
    protected $pk = 'id';
    /**
     * 表名
     * @var string
     */
    protected $name = 'base_log';

    /**
     * 操作人类型
     * @param $query
     * @param $value
     */
    public function searchOpUserTypeAttr($query, $value){
        if($value){
            $query->where('op_user_type', $value);
        }
    }

    /**
     * 操作人姓名
     * @param $query
     * @param $value
     */
    public function searchOperationUserNameAttr($query, $value){
        if($value){
            $query->where('operation_user_name','like',"%$value%");
        }
    }
    /**
     * 时间
     * @param \think\Model $query
     * @param $value
     */
    public function searchTimeAttr($query, $value){
        if($value !== ''){
            $time_arr = explode('_',$value);
            $start = strtotime($time_arr[0]);
            $end = strtotime($time_arr[1]);
            $query->whereBetweenTime('operation_time',$start,$end+86399);
        }
    }
}
